#include<iostream>
using namespace std;
typedef long long LL;
LL n, k;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> k;
		bool flag = 0;
		/*if (k & 1) {
			if ((n % k) % 2 != 0)flag = 1;
		}
		else {
			if (n & 1) {
				if (((n / 2) % (k / 2)) % 2 != 0)flag = 1;
			}
		}*/
		if (n & 1) {
			if ((k & 1) == 0) flag = 1;
		}
		if (flag) cout << "NO" << endl;
		else cout << "YES" << endl;
	}
	return 0;
}
	